﻿using System;
using System.Data;
using System.Data.SqlClient;
using Moq;

namespace JTLeigh.Commerce.Spencer.Core.Testing.Mocks.Data
{

	/// <summary>
	/// Mock database command that returns a value when <see cref="IDbCommand.ExecuteScalar"/> is
	/// called.
	/// </summary>
	[CLSCompliant(false)]
	public class MockDatabaseCommandExecuteScalarReturns : BaseMockDatabaseCommand
	{

		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="MockDatabaseCommandExecuteScalarReturns"/>
		/// class with the specified schema name, command name, parameter count, and value.
		/// </summary>
		/// <param name="schemaName">The schema name.</param>
		/// <param name="commandName">The command name.</param>
		/// <param name="parameterCount">The number of parameters that should be passed to the
		/// command.</param>
		/// <param name="value">The value to return when <see cref="IDbCommand.ExecuteScalar"/> is 
		/// called.</param>
		public MockDatabaseCommandExecuteScalarReturns(string schemaName, string commandName, int parameterCount, object value)
			: base(schemaName, commandName, parameterCount)
		{
			// value can be null

			Expect(x => x.ExecuteScalar()).Returns(value).AtMostOnce();
		}

		#endregion // Constructors

	}

}
